cmake: supernova - missing include_directories() for Jack
[supercollider.git] / Help / UGens / Playback and Recording / TGrains.html
blob58576fddfb11ffe372832cb4485b4849b07ed14d
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2 <html>
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5 <meta http-equiv="Content-Style-Type" content="text/css">
6 <title></title>
7 <meta name="Generator" content="Cocoa HTML Writer">
8 <meta name="CocoaVersion" content="824.47">
9 <style type="text/css">
10 p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Helvetica}
11 p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; min-height: 12.0px}
12 p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica}
13 p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px}
14 p.p5 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco}
15 p.p6 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #606060}
16 p.p7 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #a8220e}
17 span.s1 {color: #0013bb}
18 span.s2 {color: #000000}
19 span.s3 {color: #316f11}
20 span.Apple-tab-span {white-space:pre}
21 </style>
22 </head>
23 <body>
24 <p class="p1"><b>TGrains<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>buffer granulator</b></p>
25 <p class="p2"><br></p>
26 <p class="p3">Triggers generate grains from a single channel (mono) buffer. Each grain has a Hann envelope (sin^2(x) for x from 0 to pi) and is panned between two channels of multiple outputs.</p>
27 <p class="p4"><br></p>
28 <p class="p3"><b>TGrains.ar(numChannels, trigger, bufnum, rate, centerPos, dur, pan, amp, interp)</b></p>
29 <p class="p4"><br></p>
30 <p class="p3"><span class="Apple-tab-span"> </span><b>numChannels</b> - number of output channels.</p>
31 <p class="p3"><span class="Apple-tab-span"> </span><b>trigger</b> - at each trigger, the following arguments are sampled and used<span class="Apple-converted-space"> </span></p>
32 <p class="p3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>as the arguments of a new grain.<span class="Apple-converted-space"> </span></p>
33 <p class="p3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>A trigger occurs when a signal changes from &lt;= 0 to &gt; 0.</p>
34 <p class="p3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>If the trigger is audio rate then the grains will start with sample accuracy.</p>
35 <p class="p3"><span class="Apple-tab-span"> </span><b>bufnum</b> - the index of the buffer to use.<b> It must be a one channel (mono) buffer.</b></p>
36 <p class="p3"><span class="Apple-tab-span"> </span><b>rate</b> <span class="Apple-converted-space">  </span>-<span class="Apple-converted-space">  </span>1.0 is normal, 2.0 is one octave up, 0.5 is one octave down</p>
37 <p class="p3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>-1.0 is backwards normal rate ... etc.</p>
38 <p class="p3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>Unlike PlayBuf, the rate is multiplied by BufRate, so you needn't do that yourself.</p>
39 <p class="p3"><span class="Apple-tab-span"> </span><b>centerPos</b> - the position in the buffer in seconds at which the grain envelope will reach<span class="Apple-converted-space"> </span></p>
40 <p class="p3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>maximum amplitude.</p>
41 <p class="p3"><span class="Apple-tab-span"> </span><b>dur</b><span class="Apple-converted-space">    </span>- <span class="Apple-converted-space">  </span>duration of the grain in seconds.</p>
42 <p class="p3"><span class="Apple-tab-span"> </span><b>pan</b><span class="Apple-converted-space">    </span>- <span class="Apple-converted-space">  </span>a value from -1 to 1. Determines where to pan the output in the same manner as PanAz.</p>
43 <p class="p3"><span class="Apple-tab-span"> </span><b>amp</b> <span class="Apple-converted-space">  </span>- amplitude of the grain.</p>
44 <p class="p3"><span class="Apple-tab-span"> </span><b>interp</b> - 1,2,or 4. Determines whether the grain uses (1) no interpolation, (2) linear interpolation,<span class="Apple-converted-space"> </span></p>
45 <p class="p3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>or (4) cubic interpolation.</p>
46 <p class="p2"><br></p>
47 <p class="p2"><br></p>
48 <p class="p5">(</p>
49 <p class="p5">s = <span class="s1">Server</span>.internal;</p>
50 <p class="p5"><span class="s1">Server</span>.default = s;</p>
51 <p class="p5">s.boot;</p>
52 <p class="p5">)</p>
53 <p class="p2"><br></p>
54 <p class="p2"><br></p>
55 <p class="p6"><span class="s2">s.sendMsg(</span><span class="s3">\b_allocRead</span><span class="s2">, 10, </span>"sounds/a11wlk01.wav"<span class="s2">);</span></p>
56 <p class="p2"><br></p>
57 <p class="p2"><br></p>
58 <p class="p5">(</p>
59 <p class="p5">{</p>
60 <p class="p5"><span class="Apple-tab-span"> </span><span class="s1">var</span> b = 10, trate, dur, rate;</p>
61 <p class="p5"><span class="Apple-tab-span"> </span>trate = <span class="s1">MouseY</span>.kr(2,200,1);</p>
62 <p class="p5"><span class="Apple-tab-span"> </span>dur = 4 / trate;</p>
63 <p class="p5"><span class="Apple-tab-span"> </span>rate = Dseq([10, 1, 1, 0.5, 0.5, 0.2, 0.1], inf);</p>
64 <p class="p5"><span class="Apple-tab-span"> </span><span class="s1">TGrains</span>.ar(2, <span class="s1">Impulse</span>.ar(trate), b, <span class="s1">rate</span>, <span class="s1">MouseX</span>.kr(0,<span class="s1">BufDur</span>.kr(b)), dur, Dseq([-1, 1], inf), 0.1, 2);</p>
65 <p class="p5">}.scope(zoom: 4);</p>
66 <p class="p5">)</p>
67 <p class="p2"><br></p>
68 <p class="p5">(</p>
69 <p class="p5">{</p>
70 <p class="p5"><span class="Apple-tab-span"> </span><span class="s1">var</span> b = 10, trate, dur, clk, pos, pan;</p>
71 <p class="p5"><span class="Apple-tab-span"> </span>trate = <span class="s1">MouseY</span>.kr(8,120,1);</p>
72 <p class="p5"><span class="Apple-tab-span"> </span>dur = 12 / trate;</p>
73 <p class="p5"><span class="Apple-tab-span"> </span>clk = <span class="s1">Impulse</span>.kr(trate);</p>
74 <p class="p5"><span class="Apple-tab-span"> </span>pos = <span class="s1">MouseX</span>.kr(0,<span class="s1">BufDur</span>.kr(b)) + <span class="s1">TRand</span>.kr(0, 0.01, clk);</p>
75 <p class="p5"><span class="Apple-tab-span"> </span>pan = <span class="s1">WhiteNoise</span>.kr(0.6);</p>
76 <p class="p5"><span class="Apple-tab-span"> </span><span class="s1">TGrains</span>.ar(2, clk, b, <span class="s1">1</span>, pos, dur, pan, 0.1);</p>
77 <p class="p5">}.scope(zoom: 4);</p>
78 <p class="p5">)</p>
79 <p class="p2"><br></p>
80 <p class="p7">// 4 channels</p>
81 <p class="p5">(</p>
82 <p class="p5">{</p>
83 <p class="p5"><span class="Apple-tab-span"> </span><span class="s1">var</span> b = 10, trate, dur, clk, pos, pan;</p>
84 <p class="p5"><span class="Apple-tab-span"> </span>trate = <span class="s1">MouseY</span>.kr(8,120,1);</p>
85 <p class="p5"><span class="Apple-tab-span"> </span>dur = 12 / trate;</p>
86 <p class="p5"><span class="Apple-tab-span"> </span>clk = <span class="s1">Impulse</span>.kr(trate);</p>
87 <p class="p5"><span class="Apple-tab-span"> </span>pos = <span class="s1">MouseX</span>.kr(0,<span class="s1">BufDur</span>.kr(b)) + <span class="s1">TRand</span>.kr(0, 0.01, clk);</p>
88 <p class="p5"><span class="Apple-tab-span"> </span>pan = <span class="s1">WhiteNoise</span>.kr(0.6);</p>
89 <p class="p5"><span class="Apple-tab-span"> </span><span class="s1">TGrains</span>.ar(4, clk, b, <span class="s1">1</span>, pos, dur, pan, 0.1);</p>
90 <p class="p5">}.scope(4, zoom: 4);</p>
91 <p class="p5">)</p>
92 <p class="p2"><br></p>
93 <p class="p5">(</p>
94 <p class="p5">{</p>
95 <p class="p5"><span class="Apple-tab-span"> </span><span class="s1">var</span> b = 10, trate, dur, clk, pos, pan;</p>
96 <p class="p5"><span class="Apple-tab-span"> </span>trate = <span class="s1">MouseY</span>.kr(8,120,1);</p>
97 <p class="p5"><span class="Apple-tab-span"> </span>dur = 4 / trate;</p>
98 <p class="p5"><span class="Apple-tab-span"> </span>clk = <span class="s1">Dust</span>.kr(trate);</p>
99 <p class="p5"><span class="Apple-tab-span"> </span>pos = <span class="s1">MouseX</span>.kr(0,<span class="s1">BufDur</span>.kr(b)) + <span class="s1">TRand</span>.kr(0, 0.01, clk);</p>
100 <p class="p5"><span class="Apple-tab-span"> </span>pan = <span class="s1">WhiteNoise</span>.kr(0.6);</p>
101 <p class="p5"><span class="Apple-tab-span"> </span><span class="s1">TGrains</span>.ar(2, clk, b, <span class="s1">1</span>, pos, dur, pan, 0.1);</p>
102 <p class="p5">}.scope(zoom: 4);</p>
103 <p class="p5">)</p>
104 <p class="p2"><br></p>
105 <p class="p2"><br></p>
106 <p class="p2"><br></p>
107 <p class="p5">(</p>
108 <p class="p5">{</p>
109 <p class="p5"><span class="Apple-tab-span"> </span><span class="s1">var</span> b = 10, trate, dur, clk, pos, pan;</p>
110 <p class="p5"><span class="Apple-tab-span"> </span>trate = <span class="s1">LinExp</span>.kr(<span class="s1">LFTri</span>.kr(<span class="s1">MouseY</span>.kr(0.1,2,1)),-1,1,8,120);</p>
111 <p class="p5"><span class="Apple-tab-span"> </span>dur = 12 / trate;</p>
112 <p class="p5"><span class="Apple-tab-span"> </span>clk = <span class="s1">Impulse</span>.ar(trate);</p>
113 <p class="p5"><span class="Apple-tab-span"> </span>pos = <span class="s1">MouseX</span>.kr(0,<span class="s1">BufDur</span>.kr(b));</p>
114 <p class="p5"><span class="Apple-tab-span"> </span>pan = <span class="s1">WhiteNoise</span>.kr(0.6);</p>
115 <p class="p5"><span class="Apple-tab-span"> </span><span class="s1">TGrains</span>.ar(2, clk, b, <span class="s1">1</span>, pos, dur, pan, 0.1);</p>
116 <p class="p5">}.scope(zoom: 4);</p>
117 <p class="p5">)</p>
118 <p class="p2"><br></p>
119 <p class="p2"><br></p>
120 <p class="p5">(</p>
121 <p class="p5">{</p>
122 <p class="p5"><span class="Apple-tab-span"> </span><span class="s1">var</span> b = 10, trate, dur, clk, pos, pan;</p>
123 <p class="p5"><span class="Apple-tab-span"> </span>trate = 12;</p>
124 <p class="p5"><span class="Apple-tab-span"> </span>dur = <span class="s1">MouseY</span>.kr(0.2,24,1) / trate;</p>
125 <p class="p5"><span class="Apple-tab-span"> </span>clk = <span class="s1">Impulse</span>.kr(trate);</p>
126 <p class="p5"><span class="Apple-tab-span"> </span>pos = <span class="s1">MouseX</span>.kr(0,<span class="s1">BufDur</span>.kr(b)) + <span class="s1">TRand</span>.kr(0, 0.01, clk);</p>
127 <p class="p5"><span class="Apple-tab-span"> </span>pan = <span class="s1">WhiteNoise</span>.kr(0.6);</p>
128 <p class="p5"><span class="Apple-tab-span"> </span><span class="s1">TGrains</span>.ar(2, clk, b, <span class="s1">1</span>, pos, dur, pan, 0.1);</p>
129 <p class="p5">}.scope(zoom: 4);</p>
130 <p class="p5">)</p>
131 <p class="p2"><br></p>
132 <p class="p5">(</p>
133 <p class="p5">{</p>
134 <p class="p5"><span class="Apple-tab-span"> </span><span class="s1">var</span> b = 10, trate, dur, clk, pos, pan;</p>
135 <p class="p5"><span class="Apple-tab-span"> </span>trate = 100;</p>
136 <p class="p5"><span class="Apple-tab-span"> </span>dur = 8 / trate;</p>
137 <p class="p5"><span class="Apple-tab-span"> </span>clk = <span class="s1">Impulse</span>.kr(trate);</p>
138 <p class="p5"><span class="Apple-tab-span"> </span>pos = <span class="s1">Integrator</span>.kr(<span class="s1">BrownNoise</span>.kr(0.001));</p>
139 <p class="p5"><span class="Apple-tab-span"> </span>pan = <span class="s1">WhiteNoise</span>.kr(0.6);</p>
140 <p class="p5"><span class="Apple-tab-span"> </span><span class="s1">TGrains</span>.ar(2, clk, b, <span class="s1">1</span>, pos, dur, pan, 0.1);</p>
141 <p class="p5">}.scope(zoom: 4);</p>
142 <p class="p5">)</p>
143 <p class="p2"><br></p>
144 <p class="p5">(</p>
145 <p class="p5">{</p>
146 <p class="p5"><span class="Apple-tab-span"> </span><span class="s1">var</span> b = 10, trate, dur, clk, pos, pan;</p>
147 <p class="p5"><span class="Apple-tab-span"> </span>trate = <span class="s1">MouseY</span>.kr(1,400,1);</p>
148 <p class="p5"><span class="Apple-tab-span"> </span>dur = 8 / trate;</p>
149 <p class="p5"><span class="Apple-tab-span"> </span>clk = <span class="s1">Impulse</span>.kr(trate);</p>
150 <p class="p5"><span class="Apple-tab-span"> </span>pos = <span class="s1">MouseX</span>.kr(0,<span class="s1">BufDur</span>.kr(b));</p>
151 <p class="p5"><span class="Apple-tab-span"> </span>pan = <span class="s1">WhiteNoise</span>.kr(0.8);</p>
152 <p class="p5"><span class="Apple-tab-span"> </span><span class="s1">TGrains</span>.ar(2, clk, b, 2 ** <span class="s1">WhiteNoise</span>.kr(2), pos, dur, pan, 0.1);</p>
153 <p class="p5">}.scope(zoom: 4);</p>
154 <p class="p5">)</p>
155 <p class="p2"><br></p>
156 <p class="p2"><br></p>
157 <p class="p2"><br></p>
158 <p class="p2"><br></p>
159 <p class="p5">(</p>
160 <p class="p5">{</p>
161 <p class="p5"><span class="Apple-tab-span"> </span><span class="s1">var</span> b = 10, trate, dur;</p>
162 <p class="p5"><span class="Apple-tab-span"> </span>trate = <span class="s1">MouseY</span>.kr(2,120,1);</p>
163 <p class="p5"><span class="Apple-tab-span"> </span>dur = 1.2 / trate;</p>
164 <p class="p5"><span class="Apple-tab-span"> </span><span class="s1">TGrains</span>.ar(2, <span class="s1">Impulse</span>.ar(trate), b, (1.2 ** <span class="s1">WhiteNoise</span>.kr(3).round(1)), <span class="s1">MouseX</span>.kr(0,<span class="s1">BufDur</span>.kr(b)), dur, <span class="s1">WhiteNoise</span>.kr(0.6), 0.1);</p>
165 <p class="p5">}.scope(zoom: 4);</p>
166 <p class="p5">)</p>
167 <p class="p2"><br></p>
168 <p class="p2"><br></p>
169 <p class="p2"><br></p>
170 <p class="p2"><br></p>
171 <p class="p7">// demand ugens as inputs</p>
172 <p class="p5">(</p>
173 <p class="p5">{</p>
174 <p class="p5"><span class="Apple-tab-span"> </span><span class="s1">var</span> trate, dur, z, d;</p>
175 <p class="p5"><span class="Apple-tab-span"> </span>trate = <span class="s1">MouseX</span>.kr(1, 100, 1);</p>
176 <p class="p5"><span class="Apple-tab-span"> </span>d = { <span class="s1">Dwhite</span>(0.1, 0.2, 1) };</p>
177 <p class="p5"><span class="Apple-tab-span"> </span>z = {<span class="Apple-converted-space"> </span></p>
178 <p class="p5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s1">Drand</span>([<span class="s1">Dgeom</span>(0.1, 1 + d.value, <span class="s1">Diwhite</span>(20, 40)), <span class="s1">Dgeom</span>(1, 1 - d.value, <span class="s1">Diwhite</span>(20, 40))])<span class="Apple-converted-space"> </span></p>
179 <p class="p5"><span class="Apple-tab-span"> </span>};</p>
180 <p class="p5"><span class="Apple-tab-span"> </span><span class="s1">TGrains</span>.ar(2,<span class="Apple-converted-space"> </span></p>
181 <p class="p5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s1">Impulse</span>.ar(trate),</p>
182 <p class="p5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>bufnum: 10,<span class="Apple-converted-space"> </span></p>
183 <p class="p5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>rate: <span class="s1">Dseq</span>([1, 1, z.value, 0.5, 0.5, 0.2, 0.1, 0.1, 0.1, 0.1], <span class="s1">inf</span>) * 2 + 1,<span class="Apple-converted-space"> </span></p>
184 <p class="p5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>centerPos: <span class="s1">Dseq</span>(z.dup(8), <span class="s1">inf</span>),</p>
185 <p class="p5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>dur: <span class="s1">Dseq</span>([1, d.value, 1, z.value, 0.5, 0.5, 0.1, z.value] * 2, <span class="s1">inf</span>) / trate,</p>
186 <p class="p5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>pan: <span class="s1">Dseq</span>([1, 1, 1, 0.5, 0.2, 0.1, 0, 0, 0], <span class="s1">inf</span>) * 2 - 1,</p>
187 <p class="p5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>amp: <span class="s1">Dseq</span>([1, 0, z.value, 0, 2, 1.0, 1, 0.1, 0.1], <span class="s1">inf</span>)</p>
188 <p class="p5"><span class="Apple-tab-span"> </span>);</p>
189 <p class="p5">}.scope(zoom: 4);</p>
190 <p class="p5">)</p>
191 </body>
192 </html>